import QtQuick 1.0
import com.nokia.symbian 1.0
import "../js/Storage.js" as Storage
import "../"

Item {
    id: favoriteListItem

    width:  favoriteListItem.ListView.view.width
    height: 130

   Column {

       FontLoader {
           id: fontStyle
           name: "Helvetica"
       }

       Rectangle {
           id: favoriteListRect

           width:  favoriteListItem.width
           height: favoriteListItem.height
           color:  "#ffffff"
           border.width: 1
           border.color: "black"
           smooth: true

           Text {
               id: sessionName
               anchors.top: parent.top
               anchors.topMargin: 5
               width: parent.width

               text: name
               color:  "black"
               font.family: fontStyle.name
               font.bold: true
               font.pixelSize: 20

               wrapMode: Text.WordWrap

           }

           Text {
               id: sessionSpeaker

               anchors.top: sessionName.bottom
               anchors.topMargin: 8

               text: speaker
               color: "black"
               font.family: fontStyle.name
               wrapMode: Text.WordWrap
               font.pixelSize: 18
           }

           Text {
               id: sessionRoom

               anchors.bottom: parent.bottom
               anchors.bottomMargin: 2

               text: from + " - " + to + " " + day + " @ " + room
               color: "blue"
               font.family: fontStyle.name
               wrapMode: Text.WordWrap
               font.pixelSize: 17
           }

           FavoriteItem {
               id: sessionFavorite

               z: 1

               anchors.bottom: parent.bottom
               //anchors.bottomMargin: 2
               anchors.right: parent.right
               //anchors.rightMargin: 15

               //source: starIcon
               state: starIcon



               MouseArea {
                   anchors.fill: parent

                   onClicked: {
                       if (sessionFavorite.state == "select") {
                           sessionFavorite.state = "un-select";
                           Storage.setFavoriteCache(sessionId.text, 0);
                           favorite.removeFav(index);
                       } else {
                           sessionFavorite.state = "select"
                           Storage.setFavoriteCache(sessionId.text, 1);
                       }

                    }
               }

           }

           Text {
               id: sessionId

               text: id
               color: "black"
               visible: false
           }


           MouseArea {
               id: sessionOpenListMouse
               anchors.fill: parent

                onClicked: {
                        sessionOpenDetail.sessionDetail(sessionId.text)
                        pageStack.push(sessionOpenDetail);
                }


               onPressed: {
                   parent.color = "#f2f2f2"
               }

               onReleased: {
                   parent.color = "#ffffff"
               }

               onCanceled: {
                   parent.color = "#ffffff"
               }
           }
       }
   }

}
